import React, { Component } from 'react';
import { Modal, message, Col, Row, Tag } from 'antd';

export default class QueryAlarm extends Component {
    handleSet = () => {
        const { selectedRows, dispatch } = this.props;
        const devIds = selectedRows.join(',');

        dispatch({
            type: 'dev/queryAlarm',
            payload: { devIds },
            callback: () => {
                
                message.success('查询设备报警成功.');
            },
        });
        this.props.handleModalVisible(false);
    };

    render() {
        const { selectedRows } = this.props;
        const { modalVisible, handleModalVisible } = this.props;
        return (
            <Modal
                title="确定查询下列设备的报警么"
                visible={modalVisible}
                onOk={this.handleSet}
                onCancel={() => handleModalVisible(false)}
            >
                <Row style={{ width: '100%' }}>
                    {selectedRows.map(item => (
                        <Col span={8}>
                            <Tag>{item}</Tag>
                        </Col>
                    ))}
                </Row>
            </Modal>
        );
    }
}
